home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Blitting Class Library / Buffer Accessors / WindowAccessor.cp < prev    next >
Encoding:
Text File  |  1995-10-29  |  1.3 KB  |  54 lines  |  [TEXT/CWIE]

  1. // WindowAccessor.cp, the WindowAccessor class, to be used for direct access to
  2. //    window pixel-maps.
  3.  
  4. // copyright © 1995, Macneil Shonle. All rights reserved.
  5.  
  6. #ifndef __WINDOWACCESSOR__
  7. #include <WindowAccessor.h>
  8. #endif
  9.  
  10. #ifndef __GWORLDSETTER__
  11. #include <GWorldSetter.h>
  12. #endif
  13.  
  14. static Rect WindowToGlobalRect(WindowRef window);
  15.  
  16. // sets up direct blitting information for a window
  17. //    may throw: xalloc
  18. WindowAccessor::WindowAccessor(WindowRef window) throw(xalloc)
  19.     : VideoAccessor(::WindowToGlobalRect(window))
  20. {
  21. }
  22.  
  23. // intentionally left blank
  24. WindowAccessor::~WindowAccessor()
  25. {
  26. }
  27.  
  28. // makes a copy of the given WindowAccessor
  29. //    may throw: xalloc
  30. WindowAccessor& WindowAccessor::operator=(const WindowAccessor& wa) throw(xalloc)
  31. {
  32.     this->BufferAccessor::operator=(wa);
  33.     return *this;
  34. }
  35.  
  36. // caches in the given WindowRef's pixel information
  37. //    may throw: xalloc
  38. WindowAccessor& WindowAccessor::operator=(WindowRef window) throw(xalloc)
  39. {
  40.     construct(::WindowToGlobalRect(window));
  41.     return *this;
  42. }
  43.  
  44. // returns a global rectangle of the window's bounds
  45. Rect WindowToGlobalRect(WindowRef window)
  46. {
  47.     GWorldSetter setTo(window);
  48.     
  49.     Rect global = window->portRect;                // NOTE: directly accessing window's portRect
  50.     ::LocalToGlobal(&((Point*)&global)[0]);
  51.     ::LocalToGlobal(&((Point*)&global)[1]);
  52.     
  53.     return global;
  54. }